<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../plugins/mui/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/excutive_housekeeper/main.css" />
		<script src="../../js/statistics.js"></script>
		<style>
			.header a{
				color:#fff;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left action-back"></a>
			<h1 class="mui-title">行政办事</h1>
		</header>
		<div id='map'></div>
		<!--<div class='mui-content'>
			<ul class='mui-table-view first-ul'>
				<p class='li_title'>事项概述</p>
				<li class='mui-table-view-cell'>
					<p>业务名称</p>
					<p>啊实打实打算</p>
				</li>
				<li class='mui-table-view-cell'>
					<p>权力编码</p>
					<p>啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</p>
				</li>
				<li class='mui-table-view-cell'>
					<p>主体名称</p>
					<p></p>
				</li>
				<li class='mui-table-view-cell'>
					<p>权利类型</p>
					<p></p>
				</li>
				<li class='mui-table-view-cell'>
					<p>办理地点</p>
					<p></p>
				</li>
				<li class='mui-table-view-cell'>
					<p>办理电话</p>
					<p></p>
				</li>
				<li class='mui-table-view-cell'>
					<p>费用标准</p>
					<p></p>
				</li>
				<li class='mui-table-view-cell'>
					<p>办理期限</p>
					<p></p>
				</li>
			</ul>
			<ul class='mui-table-view'>
				<p class='li_title'>法律依据</p>
				<li class='mui-table-view-cell'>
				</li>
			</ul>
			<ul class='mui-table-view'>
				<p class='li_title'>办事条件</p>
				<li class='mui-table-view-cell'>
				</li>
			</ul>
			<ul class='mui-table-view'>
				<p class='li_title'>办事流程</p>
				<li class='mui-table-view-cell'>
					<h3>1.暂无</h3>
				</li>
			</ul>
			<ul class='mui-table-view'>
				<p class='li_title'>申报材料</p>
				<li class='mui-table-view-cell'>
				</li>
			</ul>
		</div>-->
		<script src='../../plugins/jquery/jquery-3.1.0.min.js'></script>
		<script src="../../plugins/mui/mui.min.js"></script>
		<script src="../../js/getApiToken.js"></script>
		<script src='../../plugins/template/template.js'></script>
		<script type="text/javascript" src="../../js/md5.js"></script>
		<!--<script type="text/javascript" src="../../js/judge.js" ></script>-->
		<script id="body" type="text/html">
			<div class='mui-content'>
				<ul class='mui-table-view first-ul'>
					<p class='li_title'>事项概述</p>
					<li class='mui-table-view-cell'>
						<p>业务名称:</p>
						<p>{{data.business_name}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>权力编码:</p>
						<p>{{data.right_code}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>主体名称:</p>
						<p>{{data.subject_name}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>权利类型:</p>
						<p>{{data.type_name}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>办理地点:</p>
						<p id="address">{{data.address}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>办理电话:</p>
						<p id="phone-number">{{data.telephone}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>费用标准:</p>
						<p>{{data.cost}}</p>
					</li>
					<li class='mui-table-view-cell'>
						<p>办理期限:</p>
						<p>{{data.term}}</p>
					</li>
				</ul>

				<ul class='mui-table-view'>
					<p class='li_title'>法律依据</p>
					<li class='mui-table-view-cell' id="legal_basis">
					</li>
				</ul>
				<ul class='mui-table-view'>
					<p class='li_title'>办事条件</p>
					<li class='mui-table-view-cell' id="condition">
					</li>
				</ul>
				<ul class='mui-table-view'>
					<p class='li_title'>办事流程</p>
					<li class='mui-table-view-cell'>
						<img class="work-flow" src="{{baseurl}}{{data.work_flow}}" />
						<!--<img  class="work-flow" src="http://citygo.0519ztnet.com/images/auto_headimg.png" />-->
					</li>
				</ul>
				<ul class='mui-table-view'>
					<p class='li_title'>申报材料</p>
					<li class='mui-table-view-cell' id="declare_material">

					</li>
				</ul>
			</div>
			<foot>
				<div class="telephone">
					<p id="phone-number">{{data.telephone}}</p>
				</div>
				<div class="address">
					<p>{{data.address}}</p>
				</div>
			</foot>
		</script>
		<script type="text/javascript">
			mui.init({
				gestureConfig:{
				    tap: true, //默认为true
				    longtap: true //默认为false
			    }
			});

			mui.plusReady(function() {
				var ws = plus.webview.currentWebview(),
					id = ws.pageId;
				myAnotherAjax('administration/administration/detail', 'get', {
					'id': id
				}, function(data) {
					if(data.success) {
						initData(data);
					} else {
						mui.alert("网络错误，请重新尝试");
					}
				});
				$('body').delegate('.telephone', 'tap', function(e) {
					var telephone = $('#phone-number').text();
					mui.confirm(telephone, '提示', ['拨打','取消'], function(value) {
						if(value.index == 0) {
							var Uri = plus.android.importClass("android.net.Uri");
							var Intent = plus.android.importClass("android.content.Intent");
							var number = new Uri.parse("tel:"+telephone);
							var callIntent = new Intent(Intent.ACTION_CALL, number); 
							plus.android.runtimeMainActivity().startActivity(callIntent);
						}
					});
					e.preventDefault();
				});
//				$('body').delegate('.address', 'touchstart', function(e) {
//					var address = $(this).find('p').text();
//					// 设置目标位置坐标点和其实位置坐标点
//					var map = new plus.maps.Map('map');	
//					map.getUserLocation(function(status,point) { //获取当前位置
//						plus.maps.Map.reverseGeocode(point,{},function(event){
//							var addressSrc = event.address;  // 转换后的地理位置
//							mui.openWindow({
//								url:'map.html',
//								id:'map.html',
//								extras:{
//									'address':address,
//									'startAddress':addressSrc
//								},
//								waiting:{
//									autoShow:true,//自动显示等待框，默认为true
//		      						title:'正在加载...',//等待对话框上显示的提示内容
//								}
//							})
//						},function(e){
//							alert("Failed:"+JSON.stringify(e));
//						});
//					})
//					e.preventDefault();
//				});


				$('body').delegate('.address', 'touchstart', function(e) {
					var address = $(this).find('p').text();
					// 设置目标位置坐标点和其实位置坐标点
					mui.openWindow({
								url:'map.html',
								id:'map.html',
								extras:{
									'address':address
								},
								waiting:{
									autoShow:true,//自动显示等待框，默认为true
		      						title:'正在加载...',//等待对话框上显示的提示内容
								}
					})
				});



				$('body').delegate('.work-flow', 'longtap', function(e){
					var uploadSrc = $(this).attr("src"),
						nameArray = uploadSrc.split('/'),
						name = nameArray[nameArray.length - 1],
						fileSrc;
					mui.confirm('是否保存该图片？','提示',['确定','取消'],function(value){
						if(value.index == 0){
							if(plus.device.name == 'iOS'){
								fileSrc = '_doc/' + name;
							}else{
								fileSrc = '_downloads/image' + name;
							}
							var myUpload = plus.downloader.createDownload(uploadSrc,{
								method:'get',
								filename:fileSrc
							},function(download,status){
								var filename = download.filename;
								plus.gallery.save(filename,function(){
									mui.alert('保存图片成功！');
								})
							})
							myUpload.start();
						}
						
					})
				})
			});
			//初始化数据
			function initData(data) {
				var list = {
					data: data,
					baseurl: _baseUrl
				}
				var html = template('body', list),
					condition = list.data.service_conditions,
					legal_basis = list.data.legal_basis,
					declare_material = list.data.declare_material;

				$("body").append(html);
				$("#condition").html(condition);
				$("#legal_basis").html(legal_basis);
				$("#declare_material").html(declare_material);
			}
		</script>
	</body>

</html>